package cn.edu.zxj.message_wall.controller;

import cn.edu.zxj.message_wall.model.MessageInfo;
import cn.edu.zxj.message_wall.service.MessageWallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description：
 *
 * @author: zxj
 * @date: 2023-11-07
 * @time: 22:11:01
 */
@RequestMapping("/messageWall")
@RestController
@Slf4j
public class MessageWallController {

    @Autowired
    MessageWallService messageWallService;
    @RequestMapping("/saveMessage")
    public boolean saveMessage(MessageInfo message) {
        log.info("走到后端了");
        if (!message.isLegal()) {
            return false;
        }
        return messageWallService.add(message);
    }

    @RequestMapping("/getMessages")
    public List<MessageInfo> getMessages() {
        return messageWallService.getAllMessages();
    }
}
